package io.itit.ecp.admin.provide.action.req;

import io.itit.grass.common.provide.action.req.BasePageReq;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.util.StringUtils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;


@Data
@EqualsAndHashCode(callSuper = true)
public class WarningReq extends BasePageReq {

    private String sceneProjectId;

    private String sceneEdificeId;

    private String sceneCompanyId;

    private String sceneFloorId;

    @ApiModelProperty("预警级别(1:(一级)红色预警,2:(二级)橙色预警,3:(三级)黄色预警)")
    private String thresholdLevel;

    @ApiModelProperty("消息类型(1:计量,2:碳排放,3:动态)")
    private String warningType;

    @ApiModelProperty("状态(1:未读,2:已读)")
    private String status;

    private String startTime;

    private String endTime;

    private LocalDateTime getStart() {
        return StringUtils.hasLength(startTime) ? LocalDate.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd")).atTime(LocalTime.MIN) : null;
    }

    private LocalDateTime getEnd() {
        return StringUtils.hasLength(endTime) ? LocalDate.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd")).atTime(LocalTime.MAX) : LocalDateTime.now();
    }
}
